﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMP.Master" AutoEventWireup="true"
    CodeBehind="produto.aspx.cs" Inherits="Admin.cadastros.cadastro" %>

<%@ Register Src="../UserControls/loading.ascx" TagPrefix="uc" TagName="loading" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="../scripts/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../scripts/jquery-ui-1.8.16.custom/css/custom-theme/jquery-ui-1.8.16.custom.css" />
    <script src="../scripts/js/combo.js" type="text/javascript"></script>
    <link rel="stylesheet" href="../scripts/validador/validationEngine.jquery.css" type="text/css" />
    <script src="../scripts/validador/jquery.validationEngine-en.js" type="text/javascript"
        charset="utf-8">    </script>
    <script src="../scripts/validador/jquery.validationEngine.js" type="text/javascript"
        charset="utf-8">   </script>
    <script type="text/javascript">
        $(document).ready(function () { // binds form submission and fields to the validationEngine 
            $('form').validationEngine();

            //                $('#Text1').blur(function () {
            //                    var data = document.getElementById('Text1').value.replace("/", "").replace("/", "");
            //                    var dia = data.substring(0, 2);
            //                    var mes = data.substring(2, 2);
            //                    var ano = data.substring(4, 8);
            //                    var data = new Date(ano, mes, dia);

            //                    document.getElementById('Text1').Value = data.localeFormat("dd/MM/yyyy");
            //                });
        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="padding: 30px 20px 20px 20px">
        <label class="labelCadastro" for="txtNome">
            Nome do produto:</label><asp:TextBox ID="txtNome" runat="server" CssClass="validate[minSize[10], custom[required]]"></asp:TextBox>
        <span class="SeparaCampoHor"></span>
        <br />
        <br />
        <label class="labelCadastro" for="dpdTipo">
            Tipo de Produto:</label>
        <asp:DropDownList ID="dpdTipo" runat="server" CssClass="validate[required]" DataTextField="TppDes"
            DataValueField="TppID">
        </asp:DropDownList>
        <br />
        <asp:UpdatePanel ID="upHidden" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnGravaPrecos" EventName="click" />
                <asp:PostBackTrigger ControlID="btnGravaFoto" />
                <asp:AsyncPostBackTrigger ControlID="btnSalvar" EventName="click" />
            </Triggers>
            <ContentTemplate>
                <asp:HiddenField ID="HiddenField1" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <label class="labelCadastro" for="editDescricao">
            Descrição Completa</label>
        <br />
        <CKEditor:CKEditorControl ID="editDescricao" runat="server" ToolbarFull="Source|-|Preview|-|Templates
            Cut|Copy|Paste|Undo|Redo|-|Find|Replace|-|SelectAll|RemoveFormat
            Bold|Italic|Underline|Strike|-|NumberedList|BulletedList|-|Outdent|Indent|Blockquote|
            JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock
            BidiLtr|BidiRtl
            /
            Styles|Format|Font|FontSize
            TextColor|BGColor
            Maximize|ShowBlocks|-|About">
        </CKEditor:CKEditorControl><br />
        <div>
            <table style="text-align: justify; width: 100%">
                <tr>
                    <td style="width: 42%; padding: 10px 0 0 0; vertical-align: top;">
                        <asp:UpdatePanel ID="upFotos" runat="server">
                            <Triggers>
                                <asp:PostBackTrigger ControlID="btnGravaFoto" />
                            </Triggers>
                            <ContentTemplate>
                                <fieldset style="width: 100%; clear: both;">
                                    <legend class="labelCadastro">&nbsp Fotos &nbsp </legend>
                                    <asp:FileUpload ID="fupFoto" runat="server" />
                                    <asp:Button ID="btnGravaFoto" runat="server" Text="Salvar" OnClick="btnGravaFoto_Click"
                                        ClientIDMode="Static" CausesValidation="false" CssClass="button" />
                                    <br />
                                    <br />
                                    <asp:Repeater ID="rptFotos" runat="server" OnItemCommand="rptFotos_ItemCommand">
                                        <HeaderTemplate>
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <div style="float: left; text-align: center; border: 1px; border-color: #CD661D;
                                                margin: 10px">
                                                <img src="<%#DataBinder.Eval(Container.DataItem, "PmgLoc")%>" alt="<%# DataBinder.Eval(Container.DataItem, "PmgLoc")%>"
                                                    style="width: 80px; height: 75px;" /><br />
                                                <asp:LinkButton runat="server" ID="btnExc" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PmgId")%>'>[ X ]</asp:LinkButton>
                                            </div>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                        </FooterTemplate>
                                    </asp:Repeater>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                    <td style="width: 48%; padding: 10px 0 0 20px; vertical-align: top;">
                        <asp:UpdatePanel ID="upPrecos" runat="server">
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btnGravaPrecos" EventName="click" />
                                <asp:AsyncPostBackTrigger ControlID="rptPrecos" EventName="ItemCommand" />
                            </Triggers>
                            <ContentTemplate>
                                <fieldset style="width: 100%; height: 100%">
                                    <legend class="labelCadastro">Preços </legend>
                                    <table class="tabela" style="width: 100%; margin: 0">
                                        <thead class="cabecalho">
                                            <tr>
                                                <th scope="col" colspan="1">
                                                    <strong>Tamanho</strong>
                                                </th>
                                                <th scope="col" colspan="1">
                                                    <strong>Valor</strong>
                                                </th>
                                                <th>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <asp:Repeater ID="rptPrecos" runat="server" OnItemCommand="rptPrecos_ItemCommand">
                                                <ItemTemplate>
                                                    <tr class="tblLinha">
                                                        <td class="peso ">
                                                            <%# String.Format("{0:0}",DataBinder.Eval(Container.DataItem, "PtmPes"))%>
                                                            g.
                                                        </td>
                                                        <td class="valor">
                                                            R$<%# String.Format("{0:0.00}", DataBinder.Eval(Container.DataItem, "PtmVal"))%>
                                                        </td>
                                                        <td class="valor" style="font-size: 8px">
                                                            <asp:LinkButton runat="server" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PtmId") %>'
                                                                CssClass="delete ">Deletar</asp:LinkButton>
                                                        </td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                            <tr class="tblLinha">
                                                <td class="peso">
                                                    <asp:TextBox CssClass="validate[custom[number]] numero" ID="txtPeso" runat="server"
                                                        MaxLength="4"></asp:TextBox>
                                                </td>
                                                <td class="valor">
                                                    <asp:TextBox CssClass="validate[custom[number]] numero " ID="txtValor" runat="server"></asp:TextBox>
                                                </td>
                                                <td style="font-size: 10px">
                                                    <asp:Button ID="btnGravaPrecos" runat="server" Text="Salvar" OnClick="btnGravaPrecos_Click"
                                                        CausesValidation="false" CssClass="button" />
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </fieldset>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center;">
                        <br />
                        <asp:LinkButton ID="btnSalvar" Text="Salvar e Sair" runat="server" OnClick="btnSalvar_Click"
                            OnClientClick="if(!valida()) return false;" CausesValidation="false" CssClass="button">
                        </asp:LinkButton>
                        <asp:LinkButton ID="btnSair" Text="Cancelar" runat="server" OnClick="btnSair_Click"
                            CausesValidation="false" CssClass="sair">
                        </asp:LinkButton>
                    </td>
                </tr>
            </table>
        </div>
        <asp:UpdateProgress runat="server" ID="PageUpdateProgress">
            <ProgressTemplate>
                <uc:loading runat="server" ID="ucloading" />
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
</asp:Content>
